<template>
  <div>
    <assess :editor="true"/>
    <div class="share" v-if="!isShare">
      <div class="share-item" @click="showShare">
        <img src="../../../../assets/img/icon-wx.png" alt="">
        <span>分享好友</span>
      </div>
      <div class="share-item" @click="showShare">
        <img src="../../../../assets/img/icon-friend.png" alt="">
        <span>分享朋友圈</span>
      </div>
    </div>
  </div>
</template>

<script>
import assess from '@/components/assess'
import {wxShare} from '@/utils/auth'
export default {
  name: 'assessView',
  data () {
    return {
      isShare: false
    }
  },
  methods: {
    showShare () {
      this.$store.commit('SET_SHARE_STUDENT', true)
    },
    getWXConfig () {
      let name = sessionStorage.getItem('user') ? JSON.parse(sessionStorage.getItem('user')).name : ''
      name = encodeURIComponent(name)
      let id = this.$route.query.id
      // let url = `http://sae.wecozhiku.com/course/student.html#/assessView?id=${id}&name=${name}`
      let url = `http://sae.wecozhiku.com/admin/Curriculum/url?id=${id}&name=${name}`
      wxShare({
        timeLine: {
          title: '快乐学音乐', // 分享标题
          link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
          imgUrl: 'http://sae.wecozhiku.com/course/img/share.jpg', // 分享图标
          success: () => {
            // this.$toast('分享成功')
          }
        },
        appMessage: {
          title: '快乐学音乐', // 分享标题
          desc: '有坚持就有收获、你将成为最亮的那颗星', // 分享描述
          link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
          imgUrl: 'http://sae.wecozhiku.com/course/img/share.jpg', // 分享图标
          type: '', // 分享类型,music、video或link，不填默认为link
          dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
          success: () => {
            // this.$toast('分享成功')
          }
        }
      })
    }
  },
  components: {
    assess
  },
  created () {
    this.getWXConfig()
    let name = this.$route.query.name
    if (name) {
      this.$store.commit('SET_SHOWTITLE_STUDENT', false)
      this.isShare = true
    }
  }
}
</script>

<style scoped>
  .share{
    display: flex;
    justify-content: space-around;
    margin-top: 50px;
  }
  .share .share-item{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .share .share-item span{
    font-size: 11px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 28px;
    color: rgba(153,153,153,1);
  }
</style>
